
// #ifndef VUE3
import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

App.mpType = 'app'



const app = new Vue({
    ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
import piniaPersistedState from 'pinia-plugin-persistedstate';
import { createPinia } from 'pinia';
const pinia = createPinia()
pinia.use(piniaPersistedState);

// 按需导入 $http网络请求包
import { $http } from '@escook/request-miniprogram'
uni.$http = $http
// #ifndef H5
$http.baseUrl = 'https://api-hmugo-web.itheima.net'
// #endif


// 请求开始之前做一些事情
$http.beforeRequest = function (options) {
	// console.log(pinia.state.value.user.token)
  	uni.showLoading({
    	title: '数据加载中...',
	})
	if(options.url.indexOf('/my/')!==-1){
		options.header = {
			Authorization:pinia.state.value.user.token
		}
	}
}
// 请求完成之后做一些事情
$http.afterRequest = function () {
  uni.hideLoading()
}

uni.$showMsg = function(title="数据加载失败!",duration=1500){
	uni.showToast({
		title,
		duration,
		icon:'none'
	})
}
export function createApp() {
  const app = createSSRApp(App)
  app.use(pinia)
  return {
    app
  }
}
// #endif